package com.noshufou.android.su.widget;

import android.content.Context;
import android.content.res.ColorStateList;
import android.database.Cursor;
import android.graphics.Color;
import android.support.v4.widget.CursorAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.SectionIndexer;
import android.widget.TextView;
import com.noshufou.android.su.util.Util;

public class LogAdapter extends CursorAdapter
  implements AbsListView.OnScrollListener, SectionIndexer, PinnedHeaderListView.PinnedHeaderAdapter
{
  private static final int LOG_COLUMN_DATE = 2;
  private static final int LOG_COLUMN_NAME = 1;
  private static final int LOG_COLUMN_TYPE = 3;
  public static final String[] PROJECTION;
  private Context mContext;
  private Cursor mCursor;
  private boolean mDisplaySectionHeaders = true;
  private SectionIndexer mIndexer;
  private boolean mShowName = true;

  static
  {
    String[] arrayOfString = new String[4];
    arrayOfString[0] = "_id";
    arrayOfString[1] = "name";
    arrayOfString[2] = "date";
    arrayOfString[3] = "type";
    PROJECTION = arrayOfString;
  }

  public LogAdapter(Cursor paramCursor, Context paramContext)
  {
    super(paramContext, paramCursor, false);
    this.mCursor = paramCursor;
    this.mContext = paramContext;
  }

  public LogAdapter(Cursor paramCursor, Context paramContext, boolean paramBoolean)
  {
    this(paramCursor, paramContext);
    this.mShowName = paramBoolean;
  }

  private void bindSectionHeader(View paramView, int paramInt, boolean paramBoolean)
  {
    LogListItem localLogListItem = (LogListItem)paramView;
    if (!paramBoolean)
    {
      localLogListItem.setSectionHeader(null);
      localLogListItem.setDividerVisible(true);
    }
    while (true)
    {
      return;
      int i = getSectionForPosition(paramInt);
      if (getPositionForSection(i) == paramInt)
        localLogListItem.setSectionHeader((String)this.mIndexer.getSections()[i]);
      while (true)
      {
        if (-1 + getPositionForSection(i + 1) != paramInt)
          break label99;
        localLogListItem.setDividerVisible(false);
        break;
        localLogListItem.setDividerVisible(false);
        localLogListItem.setSectionHeader(null);
      }
      label99: localLogListItem.setDividerVisible(true);
    }
  }

  private void updateIndexer(Cursor paramCursor)
  {
    if ((paramCursor == null) || (paramCursor.getCount() == 0));
    for (this.mIndexer = null; ; this.mIndexer = new DateIndexer(this.mContext, paramCursor, 2))
      return;
  }

  public void bindView(View paramView, Context paramContext, Cursor paramCursor)
  {
    LogListItem localLogListItem = (LogListItem)paramView;
    localLogListItem.setTimeText(Util.formatTime(paramContext, paramCursor.getLong(2)));
    if (this.mShowName)
      localLogListItem.setNameText(paramCursor.getString(1));
    int i = 2131427360;
    switch (paramCursor.getInt(3))
    {
    default:
    case 1:
    case 0:
    case 2:
    case 3:
    }
    while (true)
    {
      localLogListItem.setTypeText(this.mContext.getString(i));
      return;
      i = 2131427361;
      continue;
      i = 2131427362;
      continue;
      i = 2131427363;
      continue;
      i = 2131427364;
    }
  }

  public void configurePinnedHeader(View paramView, int paramInt1, int paramInt2)
  {
    PinnedHeaderListView.PinnedHeaderCache localPinnedHeaderCache = (PinnedHeaderListView.PinnedHeaderCache)paramView.getTag();
    if (localPinnedHeaderCache == null)
    {
      localPinnedHeaderCache = new PinnedHeaderListView.PinnedHeaderCache();
      localPinnedHeaderCache.titleView = ((TextView)paramView.findViewById(2131361847));
      localPinnedHeaderCache.textColor = localPinnedHeaderCache.titleView.getTextColors();
      localPinnedHeaderCache.background = paramView.getBackground();
      paramView.setTag(localPinnedHeaderCache);
    }
    int i = getSectionForPosition(paramInt1);
    String str = (String)this.mIndexer.getSections()[i];
    localPinnedHeaderCache.titleView.setText(str);
    if (paramInt2 == 255)
    {
      paramView.setBackgroundDrawable(localPinnedHeaderCache.background);
      localPinnedHeaderCache.titleView.setTextColor(localPinnedHeaderCache.textColor);
    }
    while (true)
    {
      return;
      paramView.setBackgroundColor(16777215);
      int j = localPinnedHeaderCache.textColor.getDefaultColor();
      localPinnedHeaderCache.titleView.setTextColor(Color.argb(paramInt2, Color.red(j), Color.green(j), Color.blue(j)));
    }
  }

  public boolean getDisplaySectionHeadersEnabled()
  {
    return this.mDisplaySectionHeaders;
  }

  public int getPinnedHeaderState(int paramInt)
  {
    int i = 0;
    if ((this.mIndexer == null) || (this.mCursor == null) || (this.mCursor.getCount() == 0) || (this.mCursor.isClosed()));
    while (true)
    {
      return i;
      if (paramInt < 0)
        continue;
      int j = getPositionForSection(1 + getSectionForPosition(paramInt));
      if ((j != -1) && (paramInt == j - 1))
      {
        i = 2;
        continue;
      }
      i = 1;
    }
  }

  public int getPositionForSection(int paramInt)
  {
    if (this.mIndexer == null);
    for (int i = -1; ; i = this.mIndexer.getPositionForSection(paramInt))
      return i;
  }

  public int getSectionForPosition(int paramInt)
  {
    if (this.mIndexer == null);
    for (int i = -1; ; i = this.mIndexer.getSectionForPosition(paramInt))
      return i;
  }

  public Object[] getSections()
  {
    Object localObject;
    if (this.mIndexer == null)
    {
      localObject = new String[1];
      localObject[0] = " ";
    }
    while (true)
    {
      return localObject;
      localObject = this.mIndexer.getSections();
    }
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    View localView = super.getView(paramInt, paramView, paramViewGroup);
    bindSectionHeader(localView, paramInt, true);
    return localView;
  }

  public boolean hasStableIds()
  {
    return true;
  }

  public View newView(Context paramContext, Cursor paramCursor, ViewGroup paramViewGroup)
  {
    return new LogListItem(paramContext, null);
  }

  public void onScroll(AbsListView paramAbsListView, int paramInt1, int paramInt2, int paramInt3)
  {
    if ((paramAbsListView instanceof PinnedHeaderListView))
      ((PinnedHeaderListView)paramAbsListView).configureHeaderView(paramInt1);
  }

  public void onScrollStateChanged(AbsListView paramAbsListView, int paramInt)
  {
  }

  public Cursor swapCursor(Cursor paramCursor)
  {
    this.mCursor = paramCursor;
    updateIndexer(paramCursor);
    return super.swapCursor(paramCursor);
  }
}

/* Location:           D:\Development\Decompile_Workspace\슈퍼유저-41\classes_dex2jar.jar
 * Qualified Name:     com.noshufou.android.su.widget.LogAdapter
 * JD-Core Version:    0.6.0
 */